function compile(str) {
    let tpl = str.replace(/<%=([\s\S]+? )%>/g, function (match, code) {
        return "' + obj." + code + "+ '";
    });

    tpl = "var tpl = '" + tpl + "'\nreturn tpl;";
    return new Function('obj, escape', tpl);
}

function render(compiled, data) {
    return compiled(data);
}
